﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EBAYVN.DAO;

namespace EBAYVN.CUSTOMERS.UserControl
{
    public partial class NavLeft : System.Web.UI.UserControl
    {
        private readonly NhaSanXuatDao _nsxDao = new NhaSanXuatDao();
        public int pNumber
        {
            get
            {
                if (ViewState["PgNum"] != null)
                {
                    return Convert.ToInt32(ViewState["PgNum"]);
                }
                return 0;
            }
            set
            {
                ViewState["PgNum"] = value;
            }
        }
        protected void BindNhaSanXuat()
        {
            var listnsx = _nsxDao.GetListCTNhaSanXuatByLoaiSanPham("DTDD").OrderBy(p => p.NHASANXUAT.TENNHASX).ToList();


            //int numberObjetPerpage = 20;
            //int page = pNumber;
            //if (page < 1)
            //    linkPre.Visible = false;
            //else if (page > 0)
            //    linkPre.Visible = true;
            //if (pNumber == listnsx.Count / numberObjetPerpage)
            //    linkNext.Visible = false;
            //else if (pNumber < listnsx.Count / numberObjetPerpage)
            //    linkNext.Visible = true;
            //listnsx = listnsx.Skip(numberObjetPerpage * page).Take(numberObjetPerpage).ToList();
            rpLichTrinh.DataSource = listnsx;
            rpLichTrinh.DataBind();
            upNhaSanXuat.Update();
        }
        protected void linkPre_Click(object sender, EventArgs e)
        {
            pNumber -= 1;
            BindNhaSanXuat();
        }

        protected void linkNext_Click(object sender, EventArgs e)
        {
            pNumber += 1;
            BindNhaSanXuat();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindNhaSanXuat();
            }
        }
    }
}